/*
 * v1 5/29/2011 Started this file
 * v2 5/30/2011 Fixed a few slight errors regarding storage
 * v3 5/31/2011 Added getters for testing Scheduler
 * v4 5/31/2011 (Michael) various line-wrapping edits and
 *              fixed toString method
 */

package main;

import java.util.List;
import java.util.Map;

/**
 * Contains the Feedback from the owner object. Meant for use by a Scheduler.
 * @author C Brady Mc
 * @version 5/31/2011
 */
public class Feedback {
	/**
	 * The Mapping of courses in the schedule and the students dissatisfied with them.
	 */
	private Map<Course, Integer> my_violated_students;
	
	/**
	 * The Mapping of teachers, and the courses they are dissatisfied with.
	 */
	private Map<DataUser, List<Course>> my_violated_teachers;
	
	/**
	 * The Mapping of advisors, and the courses they are dissatisfied with.
	 */
	private Map<DataUser, List<Course>> my_violated_advisors;
	
	/**
	 * The Mapping of teachers with conflicting courses, and those courses.
	 */
	private Map<String, List<String>> my_teaching_schedule;
	
	/**
	 * The Mapping of teachers who have gone over their credit limit, and their currently scheduled limit.
	 */
	private Map<String, Integer> my_teaching_limits;
	
	/**
	 * @param the_student_feedback The Student feedback for this Feedback object.
	 */
	public void setStudentFeedback(
	    final Map<Course, Integer> the_student_feedback){
	  if (the_student_feedback != null)
		my_violated_students = the_student_feedback;
	  else
	    System.out.println("Got a null in student feedback");
	}
	
	/**
	 * @param the_teacher_feedback The Teacher feedback for this Feedback object.
	 */
	public void setTeacherFeedback(final Map<DataUser, 
	    List<Course>> the_teacher_feedback){
		my_violated_teachers = the_teacher_feedback;
	}
	
	/**
	 * @param the_advisor_feedback The Advisor feedback for this Feedback object.
	 */
	public void setAdvisorFeedback(final Map<DataUser, 
	    List<Course>> the_advisor_feedback){
		my_violated_advisors = the_advisor_feedback;
	}
	
	/**
	 * @param the_teacher_courses The teachers with violated courses, and the names of those courses.
	 */
	public void setViolatedTeachingSchedule(final Map<String, 
	    List<String>> the_teacher_courses){
		my_teaching_schedule = the_teacher_courses;
	}
	
	/**
	 * @param the_teacher_limits The teachers who have gone over their credit limit, and their current credit-hours.
	 */
	public void setViolatedCreditLimits(final Map<String, Integer> the_teacher_limits){
		my_teaching_limits = the_teacher_limits;
	}
	
	/**
	 * @return The Mapping of courses in the schedule and the students dissatisfied with them.
	 */
	public Map<Course, Integer> getStudentFeedback(){
		return my_violated_students;
	}
	
	/**
	 * @return The Mapping of teachers, and the courses they are dissatisfied with.
	 */
	public Map<DataUser, List<Course>> getTeacherFeedback(){
		return my_violated_teachers;
	}
	
	/**
	 * @return The Mapping of advisors, and the courses they are dissatisfied with.
	 */
	public Map<DataUser, List<Course>> getAdvisorFeedback(){
		return my_violated_advisors;
	}
	
	/**
	 * @return The Mapping of teachers with conflicting courses, and those courses.
	 */
	public Map<String, List<String>> getViolatedTeachingSchedule(){
		return my_teaching_schedule;
	}
	
	/**
	 * @return The Mapping of teachers who have 
	 * gone over their credit limit, and their currently scheduled limit.
	 */
	public Map<String, Integer> getViolatedCreditLimits(){
		return my_teaching_limits;
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public String toString(){
		StringBuilder sb = new StringBuilder();
		for(Course c: my_violated_students.keySet()){
			sb.append("For the course " + c.getName() + 
			    ", " + my_violated_students.get(c) + 
			    " students were dissatisfied.\n");
		}
		for(DataUser teach: my_violated_teachers.keySet()){
			List<Course> hold = my_violated_teachers.get(teach);
			sb.append(((Teacher)teach).getName() + 
			    " (Teacher) was dissatisfied with these course: ");
			for(Course c: hold){
				sb.append(c.getName() + "  ");
			}
			sb.append("\n");
		}
		for(DataUser adv: my_violated_advisors.keySet()){
			List<Course> hold = my_violated_advisors.get(adv);
			sb.append(((Advisor)adv).getName() + 
			    " (Advisor) was dissatisfied with these course: ");
			for(Course c: hold){
				sb.append(c.getName() + "  ");
			}
			sb.append("\n");
		}
		for(String s: my_teaching_schedule.keySet()){
			List<String> hold = my_teaching_schedule.get(s);
			sb.append("The teacher, " + s + 
			    ", has at least two conflicting classes, " +
			    hold.get(0) + " & " + hold.get(1) + "\n");
		}
		for(String s: my_teaching_limits.keySet()){
			sb.append("The teacher, " + s + ", has " +
			    my_teaching_limits.get(s) + 
			    " credit-hours, which goes over their alloted credit-hour limit\n");
		}
		
		return sb.toString();
	}
}